<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加用户</title>
	<script type="text/javascript">
        function checkName(){
            var xhr = new XMLHttpRequest();
            var username = document.getElementById('username').value;
            xhr.onreadystatechange = function () {
                if(xhr.readyState == 4 && xhr.status==200){
                    if(xhr.responseText != "OK"){
                        alert(xhr.responseText);
                    }
                }
            }
            xhr.open('get','./check.php?username='+username+"&num=2");
            xhr.send();
        }
	</script>
</head>
<body>
<h3>添加用户</h3>
<form action="./addPerson.php?role=1" method="post" enctype="multipart/form-data">
<table width="70%" border="1" cellpadding="5" cellspacing="0" bgcolor="#cccccc">
	<tr>
		<td align="right">用户名</td>
		<td><input id="username" type="text" name="username" onblur="checkName()" placeholder="请输入用户名称"/></td>
	</tr>
	<tr>
		<td align="right">密码</td>
		<td><input type="password" name="password" /></td>
	</tr>
	<tr>
		<td colspan="2"><input type="submit"  value="添加用户"/></td>
	</tr>

</table>
</form>
</body>
</html>